var userManager = {
	lookinto : function(){
//		alert($(this).parent().parent().attr("id"));
		userManager.loadContacts($(this).parent().parent().attr("id"));
	}
	,
	showUsers : function(json){
		var strTrs = "";
		$(json).each(
			function(){
				alert(this.name);
				var strTds = "";
				strTds += "<td>"+this.name+"</td><td><input type='button' class='btn_listContacts' value='查看通讯录'/></td>";
				strTrs += "<tr id='"+this.id+"'>"+strTds+"</tr>";
			}
		);
//		alert(strTrs);
		$("#userList").append(strTrs);
		$("input").each(function(){$(this).click(userManager.lookinto)});//这里要写成userManager.lookinto,不能写this.lookinto
	},
	loadUsers : function(){
		$.getJSON("listUsers.do",userManager.showUsers);//这里要写成userManager.showUsers,不能写this.showUsers
	},
	showContacts : function (json) {
		var str = "";
		$(json).each(
			function(){
				str+=this.name+"|";
			}
		);
		$("#testshow").append(str);
	},
	loadContacts : function (id) {
		$.getJSON("findById.do",{"user.id" : id,"init":"true"},userManager.showContacts);//这里要写成userManager.showContacts
	},
	init : function () {
		$("#btn_listUsers").click(this.loadUsers);
		
		//添加"查看通讯录"按钮事件
		//传回调函数的时候不能把括号写进去
	}
	
};

$(
	function () {
		userManager.init();
//		testObject.test();
	}
);
//var testObject = {
//	test : function(){this.test2();}
//	,
//	test2 : function(){alert("test");}
//};